package org.gxuwz.core.action;

import java.util.List;

import org.gxuwz.core.entity.TArea;
import org.gxuwz.core.service.IAreaService;
import org.springframework.beans.factory.annotation.Autowired;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

public class AreaAction  extends ActionSupport implements ModelDriven<TArea>{
	TArea area = new TArea();
    List<TArea> list;
	String areacode;
	String areaname;
	 @Autowired
	    IAreaService areaService;
	    
	@Override
	public TArea getModel() {
		// TODO Auto-generated method stub
		return area;
	}
	
	public String list() {
		list = areaService.getAll(areaname, areacode);
		return "list";
	}
	
	public String getByAreaName(){
		area = areaService.getByAreaName(areaname);
		return "list";
	}
	
	public String edit(){
		area = areaService.getByAreaName(areaname);
		return "edit";
	}
	public String update(){
		areaService.update(area);
		return list();
	}
	
	public String delete(){
		area = areaService.getByAreaName(areaname);
		areaService.delete(area);
		return this.list();
	}

	public TArea getArea() {
		return area;
	}

	public void setArea(TArea area) {
		this.area = area;
	}

	public List<TArea> getList() {
		return list;
	}

	public void setList(List<TArea> list) {
		this.list = list;
	}

	public String getAreacode() {
		return areacode;
	}

	public void setAreacode(String areacode) {
		this.areacode = areacode;
	}

	public String getAreaname() {
		return areaname;
	}

	public void setAreaname(String areaname) {
		this.areaname = areaname;
	}

	public IAreaService getAreaService() {
		return areaService;
	}

	public void setAreaService(IAreaService areaService) {
		this.areaService = areaService;
	}
  

}
